package com.flowerplus.store.app;

/**
 * Created by z on.
 * Des:任务父类 所有执行操作 继承此类
 * Date: 2017/5/16
 */

public abstract class UseCase<Q extends UseCase.RequestValues, P extends UseCase.ResponseValue> {

    private Q mRequestValues;

    private UseCaseCallback<P> mUseCaseCallback;

    public void setRequestValues(Q requestValues) {
        mRequestValues = requestValues;
    }

    public Q getRequestValues() {
        return mRequestValues;
    }

    public UseCaseCallback<P> getUseCaseCallback() {
        return mUseCaseCallback;
    }

    public void setUseCaseCallback(UseCaseCallback<P> useCaseCallback) {
        mUseCaseCallback = useCaseCallback;
    }

    void run() {
        executeUseCase(mRequestValues);
    }

    protected abstract void executeUseCase(final Q requestValues);

    protected abstract void stop();

    /**
     * Data passed to a request.
     */
    public interface RequestValues {
    }

    /**
     * Data received from a request.
     */
    public interface ResponseValue {
    }

    public interface UseCaseCallback<R> {
        void onStart();

        void onSuccess(R response);

        void onError(String errorMsg);

        void onComplete();
    }
//    public interface UseCaseCallback<R> {
//        public  abstract void onSuccess(R response);
//
//        public  abstract void onError(String errorMsg);
//
//        public  void onComplete() ;
//    }
}
